<template>
	<div id="active_code_add" class="dialog animated" :class="open? 'fadeIn':'fadeOut'" v-show="show">
		<div class="panel animated" :class="open? 'zoomIn':''">
			<div class="title">
				新建活码
				<div class="close" @click="cancel()"></div>
			</div>
			<div class="form">
				<div class="row">
					<label class="label">
						<span></span>
						二维码名称
					</label>
					<el-input v-model="param.activityQrCodeName" id="activityQrCodeName" style="width: 3.5rem;" maxLength="50" placeholder="" clearable></el-input>
				</div>
				<div class="remark">* 备注名称，便于查看该二维码的扫码数据</div>
				
			</div>
			<div class="btn_div">
				<div class="btn_sure" @click="sure()">确 认</div>
				<div class="btn_cancel" @click="cancel()">取 消</div>
			</div>
		</div>
	
	</div>
</template>

<script>
var vm,user;
export default {
	data : function() {
		return {
			show : false,
			open : false,
			param : {},
		}
	},
	methods : {
		init : function(posterId) {
			vm.show = true;
			vm.open = true;
			//初始化参数
			vm.param = {
				activityQrCodeName : "",
				posterId: posterId,
				campusId : vm.$store.state.campusId,
				orgId : user.orgId,
				_wait : ""
			}
		},
		cancel : function() {
			//隐藏弹窗
			vm.open = false;
			setTimeout(function() {
				vm.show = false;
			},500);
		},
		sure : function() {
			
			//验证规则
			var rules = [{
				judge : vm.param.activityQrCodeName,
				focus : $("#active_code_add #activityQrCodeName"),
				tips : "请输入二维码名称"
			}];
			
			if(!tool.validate(rules)) {
				return;
			}
			api.activeCodeAdd(vm.param).then(function(data) {
				tool.message({ showClose: true, message: "新增成功", type: 'success' });
				vm.$emit('callback');
			    vm.cancel();
			});
			
		},
	},
	created : function() {
		vm = this;
		user = tool.getItem(lsKey.user, true);
	}
}
</script>
<style scoped src="@/style/module/dialog.css"></style>
<style scoped>
	
	.panel {
		width: 6rem;
	}
	.radio_group {
		width: 5.4rem;
		vertical-align: top;
	}
	.form {
		padding: 0 0.3rem 0 0.2rem;
		font-size: 0.16rem;
		color: #666666;
	}
	.row {
		line-height: 0.5rem;
	}
	.label {
		width: 1.1rem;
		display: inline-block;
		text-align: right;
		margin-right: 0.1rem;
	}
	.label>span {
		color: red;
		display: inline-block;
		width: 0.1rem;
		position: relative;
		top: 0.02rem;
	}
	.remark {
		line-height: 0.26rem;
		text-align: center;
		font-size: 0.14rem;
		color: #FF3030;
	}
</style>